package com.ermax.aircond.resource;

import java.util.Locale;
import java.util.ResourceBundle;

public class MessageBundle implements java.io.Serializable{
	
	private static final long serialVersionUID = 1L;
	private static final String path = "com.ermax.aircond.resource.Messages";	
	private static MessageBundle instance = null;
	private ResourceBundle rbEng = null;
	private ResourceBundle rbTrad= null;
	private ResourceBundle rbSimp = null;
	
	public MessageBundle(){		
		rbEng = ResourceBundle.getBundle(path, Locale.ENGLISH);
		rbTrad = ResourceBundle.getBundle(path, Locale.TRADITIONAL_CHINESE);
		rbSimp = ResourceBundle.getBundle(path, Locale.SIMPLIFIED_CHINESE);
	}
	
	public static MessageBundle getInstance(){
		if(instance == null){
			instance = new MessageBundle();
		}
		return instance;
	}
	
	public String getMessage(String key, Locale locale){
		if(Locale.TRADITIONAL_CHINESE.equals(locale)){
			return rbTrad.getString(key);
		}else if(Locale.SIMPLIFIED_CHINESE.equals(locale)){
			return rbSimp.getString(key);
		}else{
			return rbEng.getString(key);
		}
	}
}
